/** * @license * Copyright (c) 2014, 2018, Oracle and/or its affiliates. * The Universal Permissive License (UPL), Version 1.0 */ "use strict";define(["ojs/ojcore","jquery","ojs/ojeditablevalue"],function(e,t){var i={properties:{asyncValidators:{type:"Array",value:[]},autocomplete:{type:"string",value:"on",extension:{_COPY_TO_INNER_ELEM:!0}},autofocus:{type:"boolean",value:!1,extension:{_COPY_TO_INNER_ELEM:!0}},describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},name:{type:"string",value:"",extension:{_COPY_TO_INNER_ELEM:!0}},placeholder:{type:"string"},rawValue:{type:"string",writeback:!0,readOnly:!0},readonly:{type:"boolean",value:!1},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{regexp:{type:"object",properties:{messageDetail:{type:"string"},messageSummary:{type:"string"}}},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},validators:{type:"Array",value:[]},value:{type:"string",writeback:!0}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},n={properties:{asyncValidators:{type:"Array",value:[]},autocomplete:{type:"string",value:"on",extension:{_COPY_TO_INNER_ELEM:!0}},autofocus:{type:"boolean",value:!1,extension:{_COPY_TO_INNER_ELEM:!0}},clearIcon:{type:"string",enumValues:["always","conditional","never"],value:"never"},converter:{type:"object",properties:{type:{type:"string"},options:{type:"object"}}},describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},list:{type:"string",extension:{_COPY_TO_INNER_ELEM:!0}},messagesCustom:{type:"Array",writeback:!0,value:[]},name:{type:"string",value:"",extension:{_COPY_TO_INNER_ELEM:!0}},placeholder:{type:"string"},rawValue:{type:"string",writeback:!0,readOnly:!0},readonly:{type:"boolean",value:!1},required:{type:"boolean",value:!1},spellcheck:{type:"boolean",value:!1,extension:{_ATTRIBUTE_ONLY:!0,_COPY_TO_INNER_ELEM:!0}},translations:{type:"object",value:{},properties:{regexp:{type:"object",properties:{messageDetail:{type:"string"},messageSummary:{type:"string"}}},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},validators:{type:"Array",value:[]},value:{type:"any",writeback:!0},virtualKeyboard:{type:"string",enumValues:["auto","email","number","search","tel","text","url"],value:"auto"}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},r={properties:{asyncValidators:{type:"Array",value:[]},autocomplete:{type:"string",value:"on",extension:{_COPY_TO_INNER_ELEM:!0}},autofocus:{type:"boolean",value:!1,extension:{_COPY_TO_INNER_ELEM:!0}},converter:{type:"object",properties:{type:{type:"string"},options:{type:"object"}}},describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},name:{type:"string",value:"",extension:{_COPY_TO_INNER_ELEM:!0}},placeholder:{type:"string"},rawValue:{type:"string",writeback:!0,readOnly:!0},readonly:{type:"boolean",value:!1},required:{type:"boolean",value:!1},rows:{type:"number",extension:{_COPY_TO_INNER_ELEM:!0}},spellcheck:{type:"boolean",value:!1,extension:{_ATTRIBUTE_ONLY:!0,_COPY_TO_INNER_ELEM:!0}},translations:{type:"object",value:{},properties:{regexp:{type:"object",properties:{messageDetail:{type:"string"},messageSummary:{type:"string"}}},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},validators:{type:"Array",value:[]},value:{type:"any",writeback:!0}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}};e.__registerWidget("oj.inputBase",t.oj.editableValue,{version:"1.0.0",widgetEventPrefix:"oj",_ATTR_CHECK:[],_CLASS_NAMES:"",_WIDGET_CLASS_NAMES:"",_ELEMENT_TRIGGER_WRAPPER_CLASS_NAMES:"",_GET_INIT_OPTIONS_PROPS_FOR_WIDGET:[{attribute:"disabled",validateOption:!0},{attribute:"pattern"},{attribute:"placeholder"},{attribute:"value"},{attribute:"readonly",option:"readOnly",validateOption:!0},{attribute:"required",coerceDomValue:!0,validateOption:!0},{attribute:"title"}],_INPUT_HELPER_KEY:"",_BLUR_HANDLER_KEY:"blur",_KEYDOWN_HANDLER_KEY:"keydown",_KEYUP_HANDLER_KEY:"keyup",_INPUT_HANDLER_KEY:"input",_DROP_HANDLER_KEY:"drop",options:{asyncValidators:[],autocomplete:void 0,autofocus:!1,name:"",placeholder:"",rawValue:"",readOnly:!1,required:!1,validators:[]},_SaveAttributes:function(e){var t=this._superApply(arguments);return this._processAttrCheck(),t},_InitOptions:function(t,i){this._super(t,i),this._IsCustomElement()||e.EditableValueUtils.initializeOptionsFromDom(this._GET_INIT_OPTIONS_PROPS_FOR_WIDGET,i,this)},_ComponentCreate:function(){var e=this.element,t=this._superApply(arguments),i=(this._GetSavedAttributes(e),this.options.readOnly);return this._rtl="rtl"===this._GetReadingDirection(),"boolean"==typeof i&&this.element.prop("readonly",i),this._DoWrapElement()?(this._wrapElementInRootDomElement(),this._DoWrapElementAndTriggers()&&this._WrapElement(),this._focusable({element:this._wrapper,applyHighlight:!0})):this._focusable({element:this.element,applyHighlight:!0}),this._defaultRegExpValidator={},this._eventHandlers=null,t},_AfterCreate:function(){var i,n=this._superApply(arguments),r=this;return this._refreshRequired(this.options.required),this._CLASS_NAMES&&this.element.addClass(this._CLASS_NAMES),this._attachDetachEventHandlers(),this._AppendInputHelper(),t.each(["disabled","readOnly"],function(e,t){r.options[t]&&r._processDisabledReadOnly(t,r.options[t])}),this._IsCustomElement()&&(i=this.widget().attr("id"))&&e.EditableValueUtils.setSubIdForCustomLabelFor(this._GetContentElement()[0],i),n},_IsRequired:function(){return this.options.required},_AfterSetOptionRequired:e.EditableValueUtils._AfterSetOptionRequired,_AfterSetOptionValidators:e.EditableValueUtils._AfterSetOptionValidators,_AfterSetOptionAsyncValidators:e.EditableValueUtils._AfterSetOptionAsyncValidators,_AfterSetOptionConverter:e.EditableValueUtils._AfterSetOptionConverter,_ResetConverter:e.EditableValueUtils._ResetConverter,_GetConverter:e.EditableValueUtils._GetConverter,_GetNormalizedValidatorsFromOption:e.EditableValueUtils._GetNormalizedValidatorsFromOption,_GetNormalizedAsyncValidatorsFromOption:e.EditableValueUtils._GetNormalizedAsyncValidatorsFromOption,_processDisabledReadOnly:function(e,t){"disabled"===e&&this.element.prop("disabled",t),"readOnly"===e&&(this.element.prop("readonly",t),this._refreshStateTheming("readOnly",t)),"disabled"!==e&&"readOnly"!==e||this._attachDetachEventHandlers()},_setOption:function(t,i,n){var r=this._superApply(arguments);return"disabled"!==t&&"readOnly"!==t||this._processDisabledReadOnly(t,i),"pattern"===t&&(this._defaultRegExpValidator[e.ValidatorFactory.VALIDATOR_TYPE_REGEXP]=this._getImplicitRegExpValidator(),this._AfterSetOptionValidators()),r},_AfterSetOption:function(t,i,n){switch(this._superApply(arguments),t){case"readOnly":this._AfterSetOptionDisabledReadOnly(t,e.EditableValueUtils.readOnlyOptionOptions);break;case"required":this._AfterSetOptionRequired(t);break;case"validators":this._AfterSetOptionValidators(t);break;case"asyncValidators":this._AfterSetOptionAsyncValidators(t);break;case"converter":this._AfterSetOptionConverter(t)}},_destroy:function(){var t=this._superApply(arguments);return this.element.off("blur drop keydown keyup input"),this._inputHelper&&this._inputHelper.remove(),this._DoWrapElement()&&!this._IsCustomElement()&&(this._DoWrapElementAndTriggers()?e.DomUtils.unwrap(this.element,this._wrapper):e.DomUtils.unwrap(this.element)),t},_attachDetachEventHandlers:function(){if(this.options.readOnly||this.options.disabled){if(this._eventHandlers)for(var e=[this._BLUR_HANDLER_KEY,this._KEYDOWN_HANDLER_KEY,this._KEYUP_HANDLER_KEY,this._INPUT_HANDLER_KEY,this._DROP_HANDLER_KEY],i=0,n=e.length;i").addClass(this._WIDGET_CLASS_NAMES)),this._wrapper=this.element.parent())},_WrapElement:function(){return t(this.element).wrap(t("
").addClass(this._ELEMENT_TRIGGER_WRAPPER_CLASS_NAMES)).parent()},_AppendInputHelper:function(){if(this._INPUT_HELPER_KEY&&this._DoWrapElement()){var e=this.element.attr("aria-describedby")||"",i=this._GetSubId(this._INPUT_HELPER_KEY);e+=" "+i,this.element.attr("aria-describedby",e),this._inputHelper=t(""),this._AppendInputHelperParent().append(this._inputHelper)}},_EscapeXSS:function(e){return t(""+e+"").text()},_AppendInputHelperParent:function(){return this.widget()},_GetImplicitValidators:function(){var i=this._superApply(arguments);return this.options.pattern&&(this._defaultRegExpValidator[e.ValidatorFactory.VALIDATOR_TYPE_REGEXP]=this._getImplicitRegExpValidator()),t.extend(this._defaultRegExpValidator,i)},_CanSetValue:function(){return!!this._super()&&!(this.options.readOnly||!1)},_refreshStateTheming:function(e,t){-1!=Object.keys(this._OPTION_TO_CSS_MAPPING).indexOf(e)&&this.widget().toggleClass(this._OPTION_TO_CSS_MAPPING[e],!!t)},_getImplicitRegExpValidator:function(){if(!this.options.pattern)return null;var i={pattern:this.options.pattern,label:this._getLabelText()};return t.extend(i,this.options.translations.regexp||{}),e.Validation.validatorFactory(e.ValidatorFactory.VALIDATOR_TYPE_REGEXP).createValidator(i)},_GetSubId:function(e){return this.uuid+"_"+e},_IsRTL:function(){return this._rtl},refresh:function(){var e=this._superApply(arguments);return this._rtl="rtl"===this._GetReadingDirection(),this._refreshRequired(this.options.required),e},_refreshRequired:e.EditableValueUtils._refreshRequired,_ValidateReturnBoolean:e.EditableValueUtils._ValidateReturnBoolean,_ValidateReturnPromise:e.EditableValueUtils._ValidateReturnPromise,getNodeBySubId:function(e){return this._super(e)},validate:e.EditableValueUtils.validate,_AriaRequiredUnsupported:function(){return!1},widget:function(){return this._DoWrapElement()?this._wrapper:this.element}},!0),e.__registerWidget("oj.ojInputPassword",t.oj.inputBase,{version:"1.0.0",defaultElement:"",widgetEventPrefix:"oj",_ATTR_CHECK:[{attr:"type",setMandatory:"password"}],_CLASS_NAMES:"oj-inputpassword-input",_WIDGET_CLASS_NAMES:"oj-inputpassword oj-form-control oj-component",options:{converter:null,pattern:"",value:void 0},getNodeBySubId:function(e){var t=this._superApply(arguments);return t||"oj-inputpassword-input"===e.subId&&(t=this.element?this.element[0]:null),t||null},_GetDefaultStyleClass:function(){return"oj-inputpassword"}}),e.__registerWidget("oj.ojInputText",t.oj.inputBase,{version:"1.0.0",defaultElement:"",widgetEventPrefix:"oj",_ATTR_CHECK:[{attr:"type",setMandatory:"text"}],_CLASS_NAMES:"oj-inputtext-input",_WIDGET_CLASS_NAMES:"oj-inputtext oj-form-control oj-component",_ALLOWED_TYPES:["email","number","search","tel","text","url"],_CLICK_HANDLER_KEY:"click",options:{clearIcon:"never",converter:null,list:"",pattern:"",spellcheck:!1,virtualKeyboard:"auto"},_ComponentCreate:function(){var e=this._super(),t=this.options.clearIcon;return this._processClearIconAttr(t),this._AddHoverable(this._wrapper),this._SetInputType(this._ALLOWED_TYPES),e},_processClearIconAttr:function(e){var t=this._wrapper[0],i=t.querySelector("a.oj-inputtext-clear-icon-btn");if("never"===e||this.options.disabled||this.options.readOnly)i&&t.removeChild(i),t.classList.remove("oj-inputtext-clearicon-visible"),t.classList.remove("oj-inputtext-clearicon-conditional");else{var n;if(null===i)(i=document.createElement("a")).className="oj-inputtext-clear-icon-btn oj-component-icon oj-clickable-icon-nocontext",i.setAttribute("tabindex","-1"),i.setAttribute("target","_blank"),(n=document.createElement("span")).className="oj-inputtext-clear-icon",i.appendChild(n),t.appendChild(i),i.addEventListener(this._CLICK_HANDLER_KEY,this._onClearIconClickHandler.bind(this));if("always"===e)t.classList.add("oj-inputtext-clearicon-visible");else if(t.classList.remove("oj-inputtext-clearicon-visible"),"conditional"===e)t.classList.add("oj-inputtext-clearicon-conditional"),""!==(t.classList.contains("oj-complete")?this.element[0].value:this.options.value)?t.classList.remove("oj-form-control-empty-clearicon"):t.classList.add("oj-form-control-empty-clearicon");else t.classList.remove("oj-inputtext-clearicon-conditional"),t.classList.remove("oj-form-control-empty-clearicon")}},_AfterSetOption:function(e,t){switch(this._super(e,t),e){case"clearIcon":case"value":case"disabled":case"readOnly":this._processClearIconAttr(this.options.clearIcon);break;case"virtualKeyboard":this._SetInputType(this._ALLOWED_TYPES)}},_onInputHandler:function(e){this._super(e);var t=e.target,i=this._wrapper[0];"conditional"===this.options.clearIcon&&(""!==t.value?i.classList.remove("oj-form-control-empty-clearicon"):i.classList.add("oj-form-control-empty-clearicon"))},_onClearIconClickHandler:function(e){var t=this.element[0];t.value="",this._SetRawValue(t.value,e),t.focus(),this._wrapper[0].classList.add("oj-form-control-empty-clearicon")},_onBlurHandler:function(t){var i=this._wrapper[0],n=t.relatedTarget;n&&n.classList.contains("oj-inputtext-clear-icon-btn")&&n.parentElement&&e.DomUtils.isAncestorOrSelf(i,n.parentElement)?i.classList.add("oj-focus"):this._super(t)},getNodeBySubId:function(e){var t=this._superApply(arguments);return t||"oj-inputtext-input"===e.subId&&(t=this.element?this.element[0]:null),t||null},_GetDefaultStyleClass:function(){return"oj-inputtext"},_GetTranslationsSectionName:function(){return"oj-inputBase"},_SetInputType:e.EditableValueUtils._SetInputType}),e.__registerWidget("oj.ojTextArea",t.oj.inputBase,{version:"1.0.0",defaultElement:"